import React, { Component } from 'react'
import { Route, Switch, Redirect, withRouter } from 'react-router-dom'
import menu from './config'
// import AuthRouter from './auth'
import Utils from '../common/utils'

export default class RrivateRoute extends Component {
	constructor(props) {
		super(props);
	}
	renderRoute() {
		let arr = []
		menu.map(item => {
			// if (item.path == this.props.location.pathname) {
				if(item.checkLogin) {
					if(Utils.local('userData')) {
						arr.push(
							<Route exact key={item.path} item={item} path={item.path} render={(props) => {
								document.title = item.title
								return <item.comp {...props}></item.comp>
							}}></Route>
						)
					}
				}else {
					arr.push(
						<Route exact key={item.path} item={item} path={item.path} render={(props) => {
							document.title = item.title
							return <item.comp {...props}></item.comp>
						}}></Route>
					)
				}
			// }
		})
		return arr
	}
	render() {
		return (
			<Switch>
				{
					this.renderRoute()
				}
			</Switch>
		)
	}
}

